const express = require('express');
const router = express();
const { createRequest } = require("../lib/util")

router.get("/", (req, res) => {
    const location = req.query.location

    const data = `location=${location}&output=json&ak=cGgTd5S2EYujLGv0bAMMqCnZAEgqCXcl`

    createRequest('/telematics/v3/weather?' + data, 'GET')
        .then(result => {
            res.setHeader("Content-Type", "application/json")
            res.send(result)
        })
        .catch(err => {
            res.status(502).send('fetch error')
        })
})
module.exports = router;